---
title: 搭建Ubuntu24.04 Arm64编译环境
description: - 一台带网络端口且操作系统为Ubuntu 22.04的x86 Linux服务器。
url: "https://www.hiascend.com/document/detail/zh/Atlas%20200I%20A2/260RC1/RC/driverdevelopmentguide/atlasdg_11_0200.html"
---

# 搭建Ubuntu24.04 Arm64编译环境

#### 前提条件

- 一台带网络端口且操作系统为Ubuntu 22.04的x86 Linux服务器。
- Linux服务器已安装python、make、gcc、unzip、pigz、bison、flex、libncurses-dev、squashfs-tools、bc、device-tree-compiler、libssl-dev、cmake和rpm2cpio。

- 所有的依赖必须用root用户进行安装。
- 用户可以通过如下命令进行安装上述依赖。
  apt-get install -y python3 make gcc unzip pigz bison flex libncurses-dev squashfs-tools bc device-tree-compiler libssl-dev cmake rpm2cpio


#### 操作步骤

1. 登录Linux服务器。
2. 执行如下命令，切换至root用户。
  su - root

3. 上传Ubuntu24.04 Arm64镜像到服务器。

  a. 下载Ubuntu24.04镜像“    ubuntu-24.04-live-server-arm64.iso(https://old-releases.ubuntu.com/releases/24.04/ubuntu-24.04-live-server-arm64.iso)
”。
  b. 创建ubuntu24_04目录，例如在“/home”目录下创建ubuntu24_04目录。
    cd /home

    mkdir ubuntu24_04

    cd ubuntu24_04

  c. 上传“ubuntu-24.04-live-server-arm64.iso”镜像至ubuntu 24_04目录。
4. 安装环境依赖工具。
  apt-get update

  apt-get install qemu-user-static

5. 获取最小文件系统。

  a. 在Ubuntu 24.04镜像所在目录下执行以下命令，挂载镜像到“/mnt”目录。
    mount ubuntu-24.04-live-server-arm64.iso /mnt

  b. 执行以下命令复制ubuntu-server-minimal.squashfs到当前目录。
    cp /mnt/casper/ubuntu-server-minimal.squashfs ./

  c. 执行以下命令，解挂载“/mnt”目录。
    umount /mnt

6. 解压镜像，生成“squashfs-root”目录。
  unsquashfs ubuntu-server-minimal.squashfs

7. 配置Ubuntu的网络源。

  a. 执行以下命令，在当前目录创建sources.list文件。
    vim sources.list

    网络源配置参考如下。

```
deb https://repo.huaweicloud.com/ubuntu-ports/ noble main restricted universe multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble main restricted universe multiverse
deb https://repo.huaweicloud.com/ubuntu-ports/ noble-security main restricted universe multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble-security main restricted universe multiverse
deb https://repo.huaweicloud.com/ubuntu-ports/ noble-updates main restricted universe multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble-updates main restricted universe multiverse
deb https://repo.huaweicloud.com/ubuntu-ports/ noble-backports main restricted universe multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble-backports main restricted universe multiverse
## Not recommended
# deb https://repo.huaweicloud.com/ubuntu-ports/ noble-proposed main restricted universe multiverse
# deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble-proposed main restricted universe multiverse
```


  b. 配置完成后，按“Esc”键，再执行:wq!保存修改，并按“Enter”键退出。
  c. 执行以下命令，将sources.list文件复制到“squashfs-root/etc/apt”目录下。
    cp sources.list squashfs-root/etc/apt/

8. 执行如下命令，切换根系统。
  chroot squashfs-root

9. 执行如下命令，更新源。
  apt-get update

  若执行命令后报错“The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32”，请参见更新网络源时签名不可用。

10. 安装组件和工具。

  a. 执行如下命令，安装Linux组件。
    apt-get install unzip -y

    apt-get install vim -y

    apt-get install sysstat -y

    apt-get install libnuma1 -y

    apt-get install dmidecode -y

    apt-get install rsync -y

    apt-get install net-tools -y

    apt-get install psmisc -y

    apt-get install parted -y

    apt-get install arping -y

    apt-get install ntpdate -y

    apt-get install iproute2 -y

    apt-get install iputils-ping -y

    apt-get install mawk -y

    apt-get install cracklib-runtime -y

    apt-get install ethtool -y

    apt-get install ntp -y

    apt-get install fdisk -y

    apt-get install libssl-dev -y

    apt-get install libpam-cracklib -y

    apt-get install logrotate -y

  b. 执行如下命令，安装环境依赖工具。
    apt-get install rpm2cpio -y

    apt-get install device-tree-compiler -y

    apt-get install build-essential -y

    apt-get install Python3 -y

    apt-get install cmake -y

- 执行apt-get install命令后，回显中出现的需要获取的包与取得的包大小一致，则下载成功，如  图1
所示。
- 执行apt-get install命令后，若出现“perl：warning：xxx”相关报错、“debconf：xxx”相关报错、“Failed to retrieve available kernel versions.”以及“Failed to check for processor microcode upgrades.”报错，不影响Linux组件下载。


图1 下载成功

11. 执行如下命令，退出根系统。
  exit
